/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Control;
import Model.*;
import DBLayer.*;
import java.util.ArrayList;
import java.util.GregorianCalendar;
/**
 *
 * @author Radu
 */
public class CtrSaleOrder {
    public CtrSaleOrder() {

    }
    public ArrayList findAllSales()
    {
      DbInterfaceSaleOrder dbSale = new DbSaleOrder();
      ArrayList<SaleOrder> allSales = new ArrayList<SaleOrder>();
      allSales = dbSale.getAllSaleOrders("", false);
      return allSales;
    }
    public SaleOrder getById(String id)
    {
        DbInterfaceSaleOrder dbSale = new DbSaleOrder();
        return dbSale.getById(id, false);
    }

    public SaleOrder getByEmployeeId(String id)
    {
        DbInterfaceSaleOrder dbSale = new DbSaleOrder();
        return dbSale.getByEmployeeId(id, false);
    }
	public SaleOrder getByInvoiceId(String id)
    {
        DbInterfaceSaleOrder dbSale = new DbSaleOrder();
        return dbSale.getByInvoiceId(id, false);
    }
	public SaleOrder getByCustomerId(String id)
    {
        DbInterfaceSaleOrder dbSale = new DbSaleOrder();
        return dbSale.getByCustomerId(id, false);
    }
	public int insertSaleOrder(SaleOrder order) {
		DbInterfaceSaleOrder dbSale = new DbSaleOrder();
		return dbSale.insertSaleOrder(order);
	}
      public int updateSaleOrder(String deliveryStatus, GregorianCalendar deliveryDate)
      {
          DbInterfaceSaleOrder dbSale = new DbSaleOrder();
          SaleOrder sale = new SaleOrder();
          sale.setDeliveryStatus(deliveryStatus);
          sale.setDeliveryDate(deliveryDate);
          return  dbSale.updateSaleOrder(sale);
      }

      public void deleteSaleOrder(String saleNumber){
          DbInterfaceSaleOrder dbSale = new DbSaleOrder();
          dbSale.deleteSaleOrder(saleNumber);
      }

}
